﻿using Cirrious.CrossCore;
using Cirrious.MvvmCross.ViewModels;
using Sidvall.UI.Wpf.Presenters;
using System.Windows;

namespace WebOptimizer.UI.Wpf
{
	public partial class App : Application
	{
		private bool _setupComplete = false;

		private void DoSetup()
		{
			Sidvall.UI.Wpf.SystemContext.Current.MainWindow = this.MainWindow;
			Sidvall.UI.SystemContext.Current.NavigationManager.MaxHistoryItemCount = 2;

			var presenter = new RegionPresenter();
			var setup = new Setup(Dispatcher, presenter);
			setup.Initialize();

			var start = Mvx.Resolve<IMvxAppStart>();
			start.Start();

			_setupComplete = true;
		}

		protected override void OnActivated(System.EventArgs e)
		{
			if (!_setupComplete)
				DoSetup();

			base.OnActivated(e);
		}
	}
}
